
/**
 * All rights Reserved
 *
 * @Title: MerchantManagerMapper.java
 * @Package com.amigo.online.provider.merchant.mapper
 * @Description: (用一句话描述该文件做什么)
 * @author: zxy  QQ:1363320658
 * @date: 2018年12月19日 下午7:30:18
 * @version V1.0
 * @Copyright: 2018  All rights reserved.
 */
package com.amigo.online.provider.merchant.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.amigo.online.common.core.mybatis.MyMapper;
import com.amigo.online.provider.merchant.model.entity.MerchantManager;

/**
 * @version: V 1.0.0
 * @Description: （对类进行功能描述） 
 * @author: zxy  QQ:1363320658
 * @date: 2018年12月19日 下午7:30:18  
 *
 */

@Mapper
public interface MerchantManagerMapper extends MyMapper<MerchantManager> {

    /**
     * @Title: listMerchantManager
     * @Description: (这里用一句话描述这个方法的作用)
     * @param: @param merchantId
     * @param: @return
     * @return: List<Long>
     * @throws
     */
    @Select("select user_id from merchant_manager_tbl where merchant_id = #{merchanId} and quit = 0")
    List<Long> listMerchantManager(@Param("merchantId") long merchantId);

    /**
     * @Title: checkUserIfManager
     * @Description: (校验是否是管理员)
     * @param: @param merchantId
     * @param: @param id
     * @param: @return
     * @return: Long
     * @throws
     */
    @Select("select user_id from merchant_manager_tbl where merchant_id = #{merchantId} and user_id = #{userId} and quit = 0")
    Long checkUserIfManager(@Param("merchantId") long merchantId, @Param("userId") Long userId);

    /**
     * 检验用户是否是一些店铺的管理员  返回管理的店铺数量
     * @param userId
     * @return
     */
    @Select("select count(*) from merchant_manager_tbl where user_id = #{userId} and quit = 0")
    Integer checkUserIsManager(@Param("userId") Long userId);

    List<MerchantManager> getManagerListByMerchantId(@Param("merchantId") Long merchantId);

    @Select("select count(*) from merchant_manager_tbl where merchant_id = #{merchantId} and user_id = #{userId}")
    Integer checkManagerBefore(@Param("merchantId") Long merchantId, @Param("userId") Long userId);

    int updateQuit(MerchantManager merchantManager);

}

